import { QueryClient, useMutation } from "@tanstack/react-query";
import { useForm } from "react-hook-form";
import { userControllerSetRole } from "@/shared/api/api.user";
import { AxiosError } from "axios";
import { DisciplineService } from "@/shared/api/api.discipline";
import { ThemeService } from "@/shared/api/api.theme";

export function useRemoveTheme(id:number) {

    const queryClient = new QueryClient

    const removeThemeMutation = useMutation(
        {
            mutationFn: ThemeService.remove,
            onError: (error: (AxiosError<{ message: string }>)) => error,
        }, queryClient
    );
    const errorMessage = removeThemeMutation.error ? removeThemeMutation.error.response?.data.message : undefined;

    return {
        errorMessage,
        isSuccess: removeThemeMutation.isSuccess,
        handleSubmit: ()=>(removeThemeMutation.mutate(id)),
    };
}